﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Drawing;
using System.Windows.Forms;
using Styx;
using Styx.Combat.CombatRoutine;
using Styx.Helpers;
using Styx.Logic;
using Styx.Logic.Combat;
using Styx.Logic.Pathing;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using Styx.Logic.POI;

namespace HarmoniousVigor
{
    public partial class Druid
    {
        public bool balanceCombat()
        {
            if (Battlegrounds.IsInsideBattleground)
            {
                if (balancePVPCombat())
                    return true;
            }
            else if (characterPlayer.IsInInstance)
            {
                if (balanceDungeonCombat())
                    return true;
            }
            else
            {
                if (balanceQuestingCombat())
                    return true;
            }

            return false;
        }
        public bool balanceHeal()
        {
            if (Battlegrounds.IsInsideBattleground)
            {
                if (balancePVPHeal())
                    return true;
            }
            else if (characterPlayer.IsInInstance)
            {
                if (balanceDungeonHeal())
                    return true;
            }
            else
            {
                if (balanceQuestingHeal())
                    return true;
            }

            return false;
        }
        public bool balanceBuff()
        {
            if (Battlegrounds.IsInsideBattleground)
            {
                if (balancePVPBuff())
                    return true;
            }
            else if (characterPlayer.IsInInstance)
            {
                if (balanceDungeonBuff())
                    return true;
            }
            else
            {
                if (balanceQuestingBuff())
                    return true;
            }

            return false;
        }
        public bool balancePullSpell()
        {
            if (Battlegrounds.IsInsideBattleground)
            {
                if (balancePVPPullSpell())
                    return true;
            }
            else if (characterPlayer.IsInInstance)
            {
                if (balanceDungeonPullSpell())
                    return true;
            }
            else
            {
                if (balanceQuestingPullSpell())
                    return true;
            }

            return false;
        }

        public bool balanceRegularBehavior()
        {
            if (characterPlayer.CurrentTarget == null || characterPlayer.Mounted)
                return true;
            rangedMovement();
            faceTarget();
            AutoAttack();
            return false;
        }
        public bool balanceOneToNineCombatBehavior()
        {
            if (targetRange < 40 && !SpellManager.GlobalCooldown && !characterPlayer.CurrentTarget.HasAura("Moonfire"))
            {
                if (Utils.CastTarget("Moonfire", characterPlayer.CurrentTarget))
                    return true;
            }

            if (targetRange < 40 && SpellManager.CanCast("Wrath") && !SpellManager.GlobalCooldown)
            {
                if (characterPlayer.IsMoving)
                {
                    Navigator.PlayerMover.MoveStop();
                    StyxWoW.SleepForLagDuration();
                }
                if (Utils.CastTarget("Wrath", characterPlayer.CurrentTarget))
                    return true;
            }

            return false;
        }
    }
}
